package com.backstage.mapper;

import com.backstage.pojo.entity.SysRole;
import com.backstage.pojo.entity.SysUserRole;
import com.backstage.pojo.vo.SysRoleVo;
import com.backstage.pojo.vo.SysUserRoleVo;
import com.backstage.pojo.vo.SysUserVo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public interface SysUserRoleMapper extends BaseMapper<SysUserRole> {
    /**
     * 为用户设置角色
     *
     * @param userId 用户id
     * @param roleId 角色名字
     */
    @Update("INSERT into sys_user_role VALUES(#{userId},#{roleId})")
    void setUserRole(@Param("userId") long userId, @Param("roleId") long roleId);

    /**
     * 查找当前用户的角色
     *
     * @param userId
     * @return
     */
    @Select("select user_id,role_id from sys_user_role where user_id=#{userId}")
    List<SysUserRole> selectUserRoleByUserId(@Param("userId") long userId);

}
